<!DOCTYPE html>
<html>
<head>
	
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title>蹭一族</title>
	<!-- Bootstrap 3.3.5 -->
  <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css"  />
  <!-- Font Awesome -->
  <link rel="stylesheet" href="/static/awesome/css/font-awesome.min.css" /> 
  <!-- Ionicons -->
  <link rel="stylesheet" href="/static/ionicon/css/ionicons.min.css" />
  <!-- Theme style -->
  <link rel="stylesheet" href="/static/dist/css/AdminLTE.min.css" />
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="/static/dist/css/skins/_all-skins.min.css" />
   <link rel="stylesheet" href="/static/js/img/img.css" />
   
 <!-- 引入uploadify -->
<link href="/static/js/uploadify/uploadify.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" href="/static/js/img/img.css" type="text/css">
<!-- ./wrapper -->	

<link href="/static/bootstrapValidate/css/bootstrapValidator.min.css" rel="stylesheet" />


</head>
<body class="hold-transition skin-blue sidebar-mini">
	<form id="validateForm"
	  data-bv-message="验证不通过"
	  data-bv-feedbackicons-valid="fa fa-check"
	  data-bv-feedbackicons-invalid="fa fa-times"
	  data-bv-feedbackicons-validating="fa fa-refresh"
	 >
	 <div class="box box-danger">
            <div class="box-header with-border">
            	<input name="id" type="hidden"  />
            </div>
            <div class="box-body">
              <div class="row">
                <div class="col-xs-6">
                    
	                <div class="form-group" id="area1" >
	                  <label for="exampleInputEmail1">地区</label>
	                  <select type="text" class="form-control" id="areaCode" placeholder="请输入地区" name="areaCode">
	                  </select>
	                </div>
	                <div class="form-group">
	                  <label for="exampleInputEmail1">活动标题：</label>
	                  <input type="text" 
	                   data-bv-notempty="true" data-bv-notempty-message="活动标题不能为空" 
	                  data-bv-stringlength="true" data-bv-stringlength-max="20" data-bv-stringlength-message="请输入少于150字"
	                  class="form-control" id="title" placeholder="活动标题" name="title">
	                </div>
	                 <div class="form-group">
	                  <label for="exampleInputEmail1">排序</label>
	                  <input type="text" 
	                    data-bv-between-inclusive="true" min="0" max="99999" data-bv-between-message="请输入0-99999之间的数字"
	                  class="form-control" id="sort" name="sortOrder" placeholder="请输入排序">
	                </div>
	                <div class="form-group" id="type" >
	                  <label for="exampleInputEmail1">活动类型</label>
	                  <select type="text" class="form-control" id="type" placeholder="请输入跳转类型" name="type">
	                  		<option value="1" >商家列表</option>
	                  		<option value="2" >团购列表</option>
	                  </select>
	                </div>
	                <div class="form-group">
	                  <label for="exampleInputEmail1">图片</label>
	                  <input id="img" multi="false" type="file" showImage="true"  showBtn='true' fileType="*.jpg;*.png" fileSize="1MB" buttonText="Logo"></input>
                	  <span ><span style='color:red'>*</span>320*320(排序第五张图片 请使用 尺寸320*160)</span>
	                </div>
                </div>
              </div>
            </div>
            
       </div>
	</form>
<!-- jQuery 2.1.4 -->
<script src="/static/plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="/static/js/jqueryUi.min.1.11.4.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<!-- Bootstrap 3.3.5 -->
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
<!-- Morris.js charts 
<script src="/static/plugins/morris/morris.min.js"></script>
-->
<!-- Slimscroll -->
<script src="/static/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="/static/plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="/static/dist/js/app.min.js"></script>

<!-- layer-->
<script src="/static/layer/layer.js"></script>

<!-- layer-->
<script src="/static/js/syUI.js"></script>



<script type="text/javascript" src="/static/js/uploadify/swfobject.js"></script>
<script type="text/javascript" src="/static/js/uploadify/jquery.uploadify.js"></script>
<!-- 引入ui扩展 -->
<script src="/static/js/core.ui.js" type="text/javascript" charset="utf-8"></script>
<!-- 引入图片裁剪-->
<link rel="stylesheet" href="/static/js/tapmodo-Jcrop-1902fbc/css/jquery.Jcrop.css" type="text/css">
<script type="text/javascript" src="/static/js/tapmodo-Jcrop-1902fbc/js/jquery.Jcrop.js"></script>
<script type="text/javascript" src="/static/js/tapmodo-Jcrop-1902fbc/js/jquery.Jcrop.min.js"></script>
<!-- 浏览大图 -->
<script type="text/javascript" src="/static/js/img/img.js"></script>

<script type="text/javascript" src="/static/js/ut.js" ></script>

<!-- 引入kindeditor控件 -->
<script src="/static/js/kindeditor-4.1.10/kindeditor-all.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/bootstrapValidate/js/bootstrapValidator.min.js"></script>


<script>
	var table ;
	var id='';
	 var editor;
	<#if id??>
		id = '${id}';
	</#if>
	var openmap = function (ret) {
		if(ret){
			$("#lng").val(ret.lng);
			$("#lat").val(ret.lat);
			$("#address").val(ret.address);
		}
	}
	
	function showmap(){
		var lng =$("input[name='lng']").val();
		var lat=$("input[name='lat']").val();
		sy.amap(openmap,lat,lng);
	}
	
	var submitForm = function($dialog, $grid, $pjq) {
		//必须有 调用验证方法 不然未修改行isvalidate不通过
		$('#validateForm').data('bootstrapValidator').validate();
		if ($('#validateForm').data('bootstrapValidator').isValid()) {
			var obj = sy.serializeObject($('#validateForm'));
			var img = $('#img').getFileId();
			if(!img){
				$pjq.messager.e('图片未上传');
				return;
			}
			obj.img = img;
			if(!id){
				if(!obj.areaCode){
					$pjq.messager.e('商圈未选择');
					return;
				}
			}
			var url=sy.contextPath + '/indexActivity/save';
			$.post(url, obj, function(result) {
				if (result.code == 0) {
					$grid.fnDraw(false);
					$dialog.dialog('destroy');
				} else {
					$pjq.messager.e('添加失败,'+result.msg);
				}
			}, 'json');
		}else{
			$pjq.messager.e('请将内容填写完整');
		}
	};
	
	
	
	
	$(function(){
			$.post('/city/listByLevel', {
				level : 1
			}, function(result) {
				if (result) {
					var str = "<option value >-请选择城市-</option>";
					$.each(result,function(i,v){
						str +="<option value='"+v.code+"' level='"+v.level+"' v_name='"+v.name+"'  >"+v.name+"</option>"
					});
					$('#areaCode').html(str);
				}
			}, 'json');
			
		//sy.validateForm('#validateForm');
		 $('#validateForm').bootstrapValidator();
		 if (id != '') {
			parent.$.messager.progress({
				text : '数据加载中....'
			});
			$.post('/indexActivity/findById', {
				id : id
			}, function(result) {
				parent.$.messager.progress('close');
				if (result) {
					sy.loadForm($('#validateForm'),result);
					$('#areaCode').attr('disabled','disabled');
					$('#img').setFileId(result.img,false,true,true);
					
				}
			}, 'json');
		}
	});
	 
</script>

</body>
</html>
